#!/usr/bin/perl
use strict;
use File::Find;

my $homeDir="spidev/spiV4.5/tools/unifiedSigtranUpgrade/";
my $aldName="Ald.csv";
my $pdwName="Pdw.csv";
my $result="Result";
my $caseDir=$homeDir . "./unitTestBed/Cases/";
my $pdwTool = "perl $homeDir" . "./pdwtool.pl";
my $sigtranTool = "perl $homeDir" . "./sigtranXl2Xml.pl";
my $mofFileName = "";

sub wanted
{
	my $fileName = $File::Find::name;
	if (-f $fileName)
	{
		if ( $fileName =~ /^SCTP-MOF.*\.csv$/ )
		{
			$mofFileName = $fileName;
		}
	}
}
for (my $i=1; $i < 10; $i++)
{
	my $case = $caseDir . sprintf("TestCase%03d/", $i);
	my $pdwCmd = "$pdwTool -a $case$aldName -p $case$pdwName -o $case$result";
	print $pdwCmd;
	unlink glob "$case$result/*";
	system($pdwCmd);
	find(\&wanted, "$case$result");
	my $sigtranCmd = "$sigtranTool -i $mofFileName";	
	system($sigtranCmd);
}
